import express from 'express';
import * as houseRouter from './house.conteroller';
import { fileInterceptor, fileProcessor } from './house.middleware';
import { validateLoginData, authGuard, userGuard} from '../auth/auth.middleware';

const router = express.Router();

/**
 * 获取内容
 */
router.get('/house', userGuard, houseRouter.index);
router.get('/movie', houseRouter.index);

/**
 * 随机获取电影
 */
router.get('/randomGetMovie', houseRouter.random);

/**
 * 模糊查询
 */
router.get('/getMovieByKey', houseRouter.selectByKey);

/**
 * 获取内容(按 ID)
 */
router.get('/house/:postId', userGuard, houseRouter.houseDetail);

/**
 * 获取内容(按 ID) 后台专用
 */
router.post('/getMoviveById', userGuard, houseRouter.movieDetail);

/**
 * 获取最近影片
 */
router.post('/getRecentlyMovive', userGuard, houseRouter.recentlyMovive);

/**
 * 创建内容
 */
router.post('/movie', authGuard, houseRouter.store);

/**
 * 更新内容
 */
router.patch('/house/:postId', houseRouter.update);

/**
 * 删除内容
 */
router.delete('/house/:postId', authGuard, houseRouter.destroy);
// router.post('/houseDestroy', authGuard, houseRouter.destroy);
router.post('/movieDestroy', authGuard, houseRouter.destroy);

/**
 * 修改状态
 */
router.patch('/houseStatus/:postId', authGuard, houseRouter.status);
router.post('/changeMovieStatus', authGuard, houseRouter.status);

/**
 * 上传文件
 */
router.post('/houseFiles', authGuard, fileInterceptor, fileProcessor, houseRouter.uploads);

/**
 * 文件服务
 */
router.get('/houseFiles/:fileId/serve', houseRouter.serve);

/**
 * 获取文件 ID
 */
router.post('/getHouseFilesId', houseRouter.getFileName)

/**
 * 导出路由
 */
export default router;
